//
//  HLLiveFemaleViewCell.m
//  YueYue
//
//  Created by hulu001 on 2024/3/13.
//

#import "HLLiveFemaleViewCell.h"
#import "HLUserInfoRequest.h"

@interface HLLiveFemaleViewCell ()

@property (nonatomic, strong) UIImageView *avatarView;
@property (nonatomic, strong) UIImageView *coverView;
@property (nonatomic, strong) UIImageView *tagIconView;
@property (nonatomic, strong) QMUIButton *tagButton;
@property (nonatomic, strong) UIImageView *userStateView;
@property (nonatomic, strong) UILabel *countryLabel;
@property (nonatomic, strong) UILabel *nicknameLabel;

@end

@implementation HLLiveFemaleViewCell


-(instancetype)initWithFrame:(CGRect)frame{
    
    if (self = [super initWithFrame:frame]) {
        self.backgroundColor = UIColorWhite;
        self.layer.cornerRadius  = 8;
        self.layer.masksToBounds = YES;
        [self setupUI];
    }
    return self;
}

- (void)setupUI
{
    self.avatarView = [[UIImageView alloc] init];
    _avatarView.contentMode = UIViewContentModeScaleAspectFill;
    [self.contentView addSubview:_avatarView];
    [_avatarView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.edges.mas_equalTo(0);
    }];
    
    self.coverView = [[UIImageView alloc] initWithImage:UIImageMake(@"home_flow_cover")];
    [self.contentView addSubview:_coverView];
    [_coverView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.mas_equalTo(0);
    }];
    
    self.nicknameLabel = [[UILabel alloc] qmui_initWithFont:UIFontMediumMake(12) textColor:UIColorWhite];
    _nicknameLabel.text = @"123";
    [self.contentView addSubview:_nicknameLabel];
    [_nicknameLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.bottom.mas_equalTo(-16);
        make.right.mas_equalTo(-52);
    }];
    
    self.countryLabel = [[UILabel alloc] qmui_initWithFont:UIFontMediumMake(10) textColor:[UIColorWhite colorWithAlphaComponent:0.7]];
    [self.contentView addSubview:_countryLabel];
    [_countryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.equalTo(_nicknameLabel.mas_top).offset(-6);
        make.left.mas_equalTo(12);
    }];
    
    self.tagButton = [[QMUIButton alloc] init];
    [_tagButton setTitleColor:UIColorWhite forState:UIControlStateNormal];
    [_tagButton setBackgroundColor:[UIColorBlack colorWithAlphaComponent:0.2]];
    _tagButton.layer.masksToBounds = YES;
    _tagButton.layer.cornerRadius = 10;
    _tagButton.titleLabel.font = UIFontMediumMake(10);
    _tagButton.contentEdgeInsets = UIEdgeInsetsMake(5, 8, 5, 8);
    [self.contentView addSubview:_tagButton];
    [_tagButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.mas_equalTo(10);
        make.left.mas_equalTo(20);
    }];
    
    self.tagIconView = [[UIImageView alloc] init];
    _tagIconView.backgroundColor = HLAideColor5;
    _tagIconView.layer.masksToBounds = YES;
    _tagIconView.layer.cornerRadius = 11;
    [self.contentView addSubview:_tagIconView];
    [_tagIconView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.size.mas_equalTo(22);
        make.centerY.equalTo(_tagButton);
        make.left.equalTo(_tagButton).offset(-10);
    }];
    
    self.userStateView = [[UIImageView alloc] init];
    _userStateView.image = UIImageMake(@"live_user_follow");
    [self.contentView addSubview:_userStateView];
    [_userStateView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.right.mas_equalTo(0);
    }];
}

- (void)setModel:(HLLiveFemaleModel *)model
{
    _model = model;
    [_avatarView sd_setImageWithURL:[NSURL URLWithString:model.femaleAvatar] placeholderImage:[HLUIHelper avatarBigPlaceholder]];
    //_priceLabel.text = [NSString stringWithFormat:@"%ld", [model.videoUnitPrice integerValue]];
    _nicknameLabel.text = model.femaleNickName;
    
    NSString *animatePath = [[NSBundle mainBundle]pathForResource:@"live" ofType:@"gif"];
    self.tagIconView.image = [UIImage sd_imageWithGIFData:[NSData dataWithContentsOfFile:animatePath]];
    
    [_tagButton setTitle:[NSString stringWithFormat:@"   %@人观看", model.liveAudienceCount] forState:UIControlStateNormal];
    
    self.userStateView.hidden = YES;
    if ([model.followType isEqualToString:@"0"]) {
        self.userStateView.hidden = NO;
        self.userStateView.image = UIImageMake(@"live_user_follow");
    } else if([model.followType isEqualToString:@"2"]){
        self.userStateView.hidden = NO;
        self.userStateView.image = UIImageMake(@"live_user_ff");
    }

}


@end
